<template>
  <div class="audio">
    <section class="info" @click="toplayPage">
      <div class="thumd" :class="{ paused: paused }">
        <img :src="song?.album?.picUrl || song?.al?.picUrl" />
      </div>
      <!-- <span class="name">{{ song?.name }} - {{ song?.name }}</span> -->

      <div class="song-singer f-thide">
        <span class="song-n">{{ song?.name }}</span>
        <span v-for="(ar, i) in song?.ar || song?.artists" :key="i"
          >- {{ ar.name }}
          {{
            i === (song?.ar?.length || song?.artists?.length) - 1 ? "" : "/"
          }}</span
        >
      </div>
    </section>

    <div>
      <div
        v-if="paused"
        class="btn-play btn-paused"
        @click="$emit('audio-play')"
      >
        <span></span>
      </div>
      <div v-else class="btn-play btn-playing" @click="$emit('audio-pause')">
        <span></span>
        <span></span>
      </div>
    </div>

    <div class="play-list" @click="$emit('show-song-list')">
      <i class="iconfont icon-menu"></i>
    </div>
  </div>
</template>

<script>
export default {
  props: ["song", "songList", "paused"],

  data() {
    return {};
  },

  components: {},

  computed: {},

  methods: {
    toplayPage() {
      this.$router.push({
        path: "/song",
        query: {
          id: this.song?.id,
        },
      });
    },
  },
};
</script>
<style lang='scss' scoped>
@keyframes revolve {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.audio {
  position: relative;
  display: flex;
  align-items: center;
  height: 50px;
  background-color: #fff;
  border-top: 1px solid #ddd;

  .f-thide {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .info {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
    height: 100%;
  }

  .thumd {
    position: absolute;
    top: -3px;
    left: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 8px solid #000;
    box-sizing: border-box;
    overflow: hidden;
    animation: revolve 8s linear infinite;

    img {
      width: 100%;
    }
  }

  .song-singer {
    flex-grow: 1;
    padding-left: 60px;
    font-size: 12px;
    color: #666;

    .song-n {
      font-size: 14px;
      color: #333;
    }
  }

  .paused {
    animation-play-state: paused;
  }

  .btn-play,
  .play-list {
    width: 24px;
    height: 24px;
    margin: 0 10px;
    font-size: 14px;
    color: #666;
  }

  .btn-play {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 12px;
    border-radius: 50%;
    border: 2px solid #ccc;
  }

  .btn-playing {
    span {
      width: 15%;
      height: 50%;
      margin: 0 1px;
      background-color: #999;
    }
  }

  .btn-paused {
    span {
      margin-left: 3px;
      border-left: 10px solid #999;
      border-top: 6px solid transparent;
      border-bottom: 6px solid transparent;
    }
  }

  .play-list {
    text-align: center;
    line-height: 24px;
    color: #999;

    i {
      font-size: 24px;
    }
  }
}
</style>